package org.jeecg.modules.ws.service.impl;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.ws.entity.WsProjectSb;
import org.jeecg.modules.ws.mapper.WsProjectSbMapper;
import org.jeecg.modules.ws.service.IWsProjectSbService;
import org.jeecg.modules.ws.vo.ProjectSbListVo;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @Description: 债券_申报
 * @Author: jeecg-boot
 * @Date:   2025-03-27
 * @Version: V1.0
 */
@Service
public class WsProjectSbServiceImpl extends ServiceImpl<WsProjectSbMapper, WsProjectSb> implements IWsProjectSbService {



    @Override
    public WsProjectSb getOneByProductIdWithThisYear(String projectCode) {
        LambdaQueryWrapper<WsProjectSb> query = Wrappers.lambdaQuery(WsProjectSb.class);
        query.eq(WsProjectSb::getProjectCode,projectCode).eq(WsProjectSb::getSqnd, DateUtil.year(new Date()));
        return getOne(query);
    }

    @Override
    public IPage<ProjectSbListVo> queryByProductCode(Integer pageNo, Integer pageSize, String projectCode) {
        IPage<ProjectSbListVo> page = new Page<>();
        page.setCurrent(pageNo);
        page.setSize(pageSize);
        return baseMapper.queryByProductCode(page,projectCode);
    }

    @Override
    public List<WsProjectSb> queryByProductCode(String projectCode) {
        LambdaQueryWrapper<WsProjectSb> query = Wrappers.lambdaQuery(WsProjectSb.class);
        query.eq(WsProjectSb::getProjectCode,projectCode);
        return list(query);
    }
}
